//
//  NYMenu.m
//  NOAHWM
//
//  Created by Ryan on 13-6-15.
//  Copyright (c) 2013年 Ryan. All rights reserved.
//

#import "NYMenu.h"
#import "NSMutableArray+DeepCopy.h"

@implementation NYMenu

@synthesize children,funcId,funcName,isSticky;

- (id)init
{
    if(self = [super init])
    {
        self.children = [NSMutableArray array];
    }
    return self;
}

- (void)dealloc
{
    [children release];
    [funcName release];
    [funcId release];
    [super dealloc];
}

- (BOOL)isEqual:(NYMenu *)obj
{
    if(![self.funcId isEqualToString:obj.funcId])
        return NO;
    if(self.children.count != obj.children.count)
        return NO;
    for(NSInteger i = 0; i < self.children.count; i++)
    {
        NYMenu *originalMenu = [self.children objectAtIndex:i];
        NYMenu *compareMenu = [obj.children objectAtIndex:i];
        if(![originalMenu.funcId isEqualToString:compareMenu.funcId])
            return NO;
    }
    return YES;
}

#pragma mark - NSCopying methods
- (id)copyWithZone:(NSZone *)zone
{
    NYMenu *menu = [[NYMenu alloc] init];
    menu.funcId = self.funcId;
    menu.funcName = self.funcName;
    menu.isSticky = self.isSticky;
    menu.children = [self.children deepCopy];
    return menu;
}

@end
